<template>
  <main class="wss-container">
    <ComTabs
      @EventSelectTab="currentSelect"
      activeName="content"
      :tabList="tabList"
    ></ComTabs>
    <div class="label-box-content">
      <!-- <NewCard
        :border="false"
        :isright="true"
        :style="{ 'margin-bottom': padding }"
        title="内容定价"
      >
        <template #right>
          <ComForm
            @EventReset="reset"
            :list="comForm"
            @EventOnsubmit="inquireFn"
          ></ComForm>
        </template>
      </NewCard> -->

      <div class="content-box">
        <el-row :gutter="20">
          <el-col :span="16">
            <NewCard
              :title="currentTitile"
              class="table"
              :border="false"
              :isright="true"
              :style="{ 'margin-bottom': padding }"
            >
              <!-- 咨询 -->
              <template #right v-if="tabname == 'consult'">
                <el-form ref="queryForm" >
                  <!-- 一级类别 -->
                  <el-form-item>
                    <el-select
                      v-model="consultform.consultType1"
                      placeholder="一级类别"
                      @change="changeConsultOne(consultform)"
                    >
                      <el-option
                        v-for="(item,index) in consultTypeList"
                        :key="item.id+index"
                        :label="item.name"
                        :value="item.id"
                      >
                      </el-option>
                    </el-select>
                  </el-form-item>
                  <!-- consultTypeTwoList -->
                  <!-- 二级类别 -->
                  <el-form-item>
                    <el-select
                      v-model="consultform.consultType2"
                      placeholder="二级类别"
                      @change="changeConsultTwo(consultform)"
                    >
                      <el-option
                        v-for="(item,index) in consultTypeTwoList"
                        :key="item.id+index"
                        :label="item.name"
                        :value="item.id"
                      >
                      </el-option>
                    </el-select>
                  </el-form-item>
                  <!-- 专家等级 -->
                  <el-form-item prop="noticeType" >
                    <el-select
                      v-model="consultform.expertRank"
                      placeholder="专家等级"
                      @change="BrowseFromFn(consultform)"
                    >
                      <el-option
                        v-for="item in Browseoptions"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value"
                      >
                      </el-option>
                    </el-select>
                  </el-form-item>
                  <!-- 咨询名称 -->
                  <div class="topRight">
                    <el-input v-model="consulttopSearchValue" placeholder="请输入咨询名称" class="topSearch" @input="consultchangeValue" @focus="consultfocusInput" @blur="consultblurInput" ref="topSearch">
                      <i slot="suffix">
                        <svg-icon icon-class="ss_icon" />
                      </i>
                    </el-input>
                    <div class="topSearchFind" v-show="searchFindShow">
                      <ul>
                        <!-- 一级 -->
                        <li v-for="(list,index) in consultallList" :key="list.id" @mousedown.prevent="consultclickSearchList(list,index)">
                          {{list.name}}
                        </li>
                      </ul>
                    </div>
                  </div>
                  <!-- <el-form-item>
                    <el-button
                      type="primary"
                      size="mini"
                      style="
                        border-radius: 20px;
                        background-color: #f87a23;
                        border-color: #f87a23;
                        color: white;
                      "
                      @click="BrowseFromFn(consultform)"
                      >搜索</el-button
                    >
                  </el-form-item> -->
                </el-form>
              </template>
              <!-- 项目 -->
              <template slot="right" v-else-if="tabname == 'project'">
                <!-- 输入项目名称 -->
                <el-form ref="projectForm">
                  <!-- 一级类别 -->
                  <el-form-item>
                    <el-select
                      v-model="projectform.projectType1"
                      placeholder="一级类别"
                      @change="changeProjectOne(projectform)"
                    >
                      <el-option
                        v-for="(item,index) in projectTypeList"
                        :key="item.id+index"
                        :label="item.name"
                        :value="item.id"
                      >
                      </el-option>
                    </el-select>
                  </el-form-item>
                  <!-- 二级类别 -->
                  <el-form-item>
                    <el-select
                      v-model="projectform.projectType2"
                      placeholder="二级类别"
                      @change="changeProjectTwo(projectform)"
                    >
                      <el-option
                        v-for="(item,index) in projectTypeTwoList"
                        :key="item.id+index"
                        :label="item.name"
                        :value="item.id"
                      >
                      </el-option>
                    </el-select>
                  </el-form-item>
                  <div class="topRight">
                    <el-input v-model="topSearchValue" placeholder="请输入项目名称" class="topSearch" @input="changeValue" @focus="focusInput" @blur="blurInput" ref="topSearch">
                      <i slot="suffix">
                        <svg-icon icon-class="ss_icon" />
                      </i>
                    </el-input>
                    <div class="topSearchFind" v-show="searchFindShow">
                      <ul>
                        <!-- 一级 -->
                        <li v-for="(list,index) in allList" :key="list.id" @mousedown.prevent="clickSearchList(list,index)">
                          {{list.name}}
                        </li>
                      </ul>
                    </div>
                  </div>
                </el-form>
              </template>
              <div>
                <ComTable
                  @EventRowClick="RowClickFn"
                  @handleSizeChange="handleSizeChange"
                  @handleCurrentChange="handleCurrentChange"
                  :pagination="{
                    total: pageing.total,
                    pageNum: pageing.pageNum,
                    pageSize: pageing.pageSize,
                  }"
                  :list="tableList"
                  :modes="tableModes"
                >
                </ComTable>
              </div>
            </NewCard>
          </el-col>
          <el-col :span="8">
            <NewCard title="编辑" class="edit-box">
              <div class="edit-div">
                <!-- 内容定价 -->
                <el-form
                  ref="form"
                  v-if="currentType == 'content'"
                  :model="editForm"
                  :rules="rules"
                  label-position="left"
                >
                  <el-form-item
                    label="定价类型"
                    :label-width="formLabelWidth"
                    prop="pricType"
                  >
                    <el-input v-model="editForm.type" disabled></el-input>
                  </el-form-item>
                  <el-form-item
                    label="常数(元)"
                    :label-width="formLabelWidth"
                    prop="base"
                  >
                    <el-input
                      v-model="editForm.base"
                      autocomplete="off"
                      placeholder="请输入常数价格"
                    ></el-input>
                  </el-form-item>
                  <el-form-item
                    label="交付拨比(%)"
                    :label-width="formLabelWidth"
                    prop="expertCommission"
                  >
                    <el-input
                      v-model="editForm.expertCommission"
                      autocomplete="off"
                      placeholder="请输入百分比"
                    ></el-input>
                  </el-form-item>
                  <el-form-item
                    label="管理拨比(%)"
                    :label-width="formLabelWidth"
                    prop="operationsCommission"
                  >
                    <el-input
                      v-model="editForm.operationsCommission"
                      autocomplete="off"
                      placeholder="请输入百分比"
                    ></el-input>
                  </el-form-item>
                  <el-form-item
                    label="实体拨比(%)"
                    :label-width="formLabelWidth"
                    prop="organizationCommission"
                  >
                    <el-input
                      v-model="editForm.organizationCommission"
                      autocomplete="off"
                      placeholder="请输入百分比"
                    ></el-input>
                  </el-form-item>

                  <SubBtn>
                    <template slot="btn">
                      <el-button size="mini" @click="reset" round
                        >重设</el-button
                      >
                      <el-button
                        v-hasPermi="['financial:priceCommission:edit','financial:toolPrice:edit']"
                        round
                        size="mini"
                        :disabled="editForm.type == '' ? true : false"
                        type="primary"
                        @click="comfirmEdit"
                        >确 定</el-button
                      >
                    </template>
                  </SubBtn>
                </el-form>
                <!-- 内容定价 end -->

                <!-- 咨询定价 -->
                <el-form
                  ref="form"
                  label-position="left"
                  v-if="currentType == 'consult'"
                  :model="editForm"
                  :rules="rules"
                >
                  <el-form-item
                    label="咨询类型"
                    :label-width="formLabelWidth"
                    prop="pricType"
                  >
                    <el-input v-model="editForm.consultTypeName" disabled></el-input>
                  </el-form-item>
                  <el-form-item
                    label="常数(元)"
                    :label-width="formLabelWidth"
                    prop="base"
                  >
                    <el-input
                      v-model="editForm.base"
                      autocomplete="off"
                      placeholder="请输入常数价格"
                    ></el-input>
                  </el-form-item>
                  <el-form-item
                    label="交付分成"
                    :label-width="formLabelWidth"
                    prop="expertCommission"
                  >
                    <el-input
                      v-model="editForm.expertCommission"
                      autocomplete="off"
                      placeholder="请输入分成金额"
                    ></el-input>
                  </el-form-item>
                  <el-form-item
                    label="管理拨比(%)"
                    :label-width="formLabelWidth"
                    prop="operationsCommission"
                  >
                    <el-input
                      v-model="editForm.operationsCommission"
                      autocomplete="off"
                      placeholder="请输入百分比"
                    ></el-input>
                  </el-form-item>
                  <el-form-item
                    label="实体拨比(%)"
                    :label-width="formLabelWidth"
                    prop="organizationCommission"
                  >
                    <el-input
                      v-model="editForm.organizationCommission"
                      autocomplete="off"
                      placeholder="请输入百分比"
                    ></el-input>
                  </el-form-item>

                  <SubBtn>
                    <template slot="btn">
                      <el-button size="mini" @click="reset" round
                        >重设</el-button
                      >
                      <el-button
                        v-hasPermi="['financial:priceCommission:edit',,'financial:toolPrice:edit']"
                        round
                        size="mini"
                        :disabled="editForm.consultWay == '' ? true : false"
                        type="primary"
                        @click="comfirmEdit"
                        >确 定</el-button
                      >
                    </template>
                  </SubBtn>
                </el-form>
                <!-- 咨询定价 end-->

                <!-- 项目定价 -->
                <el-form
                  ref="form"
                  label-position="left"
                  v-if="currentType == 'project'"
                  :model="editForm"
                  :rules="rules"
                >
                  <el-form-item
                    label="项目类别"
                    :label-width="formLabelWidth"
                    prop="pricType"
                  >
                    <el-input v-model="editForm.name" disabled></el-input>
                  </el-form-item>

                  <el-form-item
                    label="常数(元)"
                    :label-width="formLabelWidth"
                    prop="base"
                  >
                    <el-input
                      v-model="editForm.base"
                      autocomplete="off"
                      placeholder="请输入常数价格"
                    ></el-input>
                  </el-form-item>
                  <el-form-item
                    label="交付分成"
                    :label-width="formLabelWidth"
                    prop="expertCommission"
                  >
                    <el-input
                      v-model="editForm.expertCommission"
                      autocomplete="off"
                      placeholder="请输入分成金额"
                    ></el-input>
                  </el-form-item>
                  <el-form-item
                    label="管理拨比(%)"
                    :label-width="formLabelWidth"
                    prop="operationsCommission"
                  >
                    <el-input
                      v-model="editForm.operationsCommission"
                      autocomplete="off"
                      placeholder="请输入百分比"
                    ></el-input>
                  </el-form-item>
                  <el-form-item
                    label="实体拨比(%)"
                    :label-width="formLabelWidth"
                    prop="organizationCommission"
                  >
                    <el-input
                      v-model="editForm.organizationCommission"
                      autocomplete="off"
                      placeholder="请输入百分比"
                    ></el-input>
                  </el-form-item>

                  <SubBtn>
                    <template slot="btn">
                      <el-button size="mini" @click="reset" round
                        >重设</el-button
                      >
                      <el-button
                        v-hasPermi="['financial:priceCommission:edit',,'financial:toolPrice:edit']"
                        round
                        size="mini"
                        :disabled="editForm.consultWay == '' ? true : false"
                        type="primary"
                        @click="comfirmEdit"
                        >确 定</el-button
                      >
                    </template>
                  </SubBtn>
                </el-form>
                <!-- 项目定价 end-->

                <!-- 工具定价 -->
                <el-form
                  ref="form"
                  label-position="left"
                  v-if="currentType == 'tool'"
                  :model="editForm"
                  :rules="rules"
                >
                  <el-form-item
                    label="工具类型"
                    :label-width="formLabelWidth"
                    prop="pricType"
                  >
                    <el-input v-model="editForm.type" disabled></el-input>
                  </el-form-item>
                  <el-form-item
                    label="常数(元)"
                    :label-width="formLabelWidth"
                    prop="base"
                    v-if="editForm.type == '合同智审'|| editForm.type == '模拟诉讼'|| editForm.type == '税账医生'"
                  >
                    <el-input
                      v-model="editForm.base"
                      autocomplete="off"
                      placeholder="请输入常数价格"
                    ></el-input>
                  </el-form-item>
                  <el-form-item
                    label="交付分成"
                    :label-width="formLabelWidth"
                    prop="expertCommission"
                    v-if="editForm.type == '合同智审'||editForm.type == '模拟诉讼'|| editForm.type == '税账医生'"
                  >
                    <el-input
                      v-model="editForm.expertCommission"
                      autocomplete="off"
                      placeholder="请输入分成金额"
                    ></el-input>
                  </el-form-item>
                  <el-form-item
                    label="管理拨比(%)"
                    :label-width="formLabelWidth"
                    prop="operationsCommission"
                  >
                    <el-input
                      v-model="editForm.operationsCommission"
                      autocomplete="off"
                      placeholder="请输入百分比"
                    ></el-input>
                  </el-form-item>
                  <el-form-item
                    label="实体拨比(%)"
                    :label-width="formLabelWidth"
                    prop="organizationCommission"
                  >
                    <el-input
                      v-model="editForm.organizationCommission"
                      autocomplete="off"
                      placeholder="请输入百分比"
                    ></el-input>
                  </el-form-item>
                  <!-- --------------------- 合同文控 --------------------- -->
                  <el-form-item
                    label="试用份数"
                    :label-width="formLabelWidth"
                    v-if="editForm.type == '合同文控'"
                  >
                    <el-input v-model.number="editConWis.trialNum" placeholder="请输入试用份数"></el-input>
                  </el-form-item>
                  <el-form-item
                    label="合同份数"
                    :label-width="formLabelWidth"
                    v-if="editForm.type == '合同文控'"
                    class="lableTop"
                    v-hasPermi="['financial:priceCommission:addlistCover','financial:toolPrice:addlistCover']"
                  >
                    <div class="docControl-box" v-for="(doc,index) in docControl" :key="index">
                      <i class="el-icon-remove" @click="removeDocCon(index)"></i>
                      <el-input v-model="doc.min"></el-input>
                      <p>~</p>
                      <el-input v-model="doc.max"></el-input>
                      <p>份，每份</p>
                      <el-input v-model="doc.amount"></el-input>
                      <p>问金；</p>
                    </div>
                    <div class="addBtn">
                      <svg-icon icon-class="add-icon" class="edit_add" @click="addDocCon"/>
                    </div>
                  </el-form-item>
                  <!--  ---------------------合同文控--------------------- end -->

                  <!-- ---------------------阿米巴预算/CRM/微赞/微考勤/OKR--------------------- -->
                  <el-form-item
                    label="试用期(天)"
                    :label-width="formLabelWidth"
                    label-position="top"
                    v-if="editForm.type == '阿米巴预算' || editForm.type == 'CRM' || editForm.type == '微赞' || editForm.type == '微考勤' || editForm.type == 'OKR'"
                  >
                    <el-input
                      v-model.number="editConWis.trialDays"
                      autocomplete="off"
                      placeholder="请输入试用期(天)"
                    ></el-input>
                  </el-form-item>
                  <el-form-item
                    label="试用人数"
                    :label-width="formLabelWidth"
                    v-if="editForm.type == '阿米巴预算' || editForm.type == 'CRM' || editForm.type == '微赞' || editForm.type == '微考勤' || editForm.type == 'OKR'"
                  >
                    <el-input
                      v-model.number="editConWis.trialNum"
                      autocomplete="off"
                      placeholder="请输入试用人数"
                    ></el-input>
                  </el-form-item>
                  <el-form-item
                    label="购买人数"
                    :label-width="formLabelWidth"
                    v-if="editForm.type == '阿米巴预算' || editForm.type == 'CRM' || editForm.type == '微赞' || editForm.type == '微考勤' || editForm.type == 'OKR'"
                    class="lableTop"
                    v-hasPermi="['financial:priceCommission:addlistCover','financial:toolPrice:addlistCover']"
                  >
                    <div class="docControl-box" v-for="(wsid,index) in wisdomBudgetUnit" :key="index">
                      <i class="el-icon-remove" @click="removeUnitCon(index)"></i>
                      <el-input v-model="wsid.min"></el-input>
                      <p>~</p>
                      <el-input v-model="wsid.max"></el-input>
                      <p>人，每人每年</p>
                      <el-input v-model="wsid.amount"></el-input>
                      <p>问金；</p>
                    </div>
                    <div class="addBtn">
                      <svg-icon icon-class="add-icon" class="edit_add" @click="addUnitCon"/>
                    </div>
                  </el-form-item>
                  <el-form-item
                    label="购买时长"
                    :label-width="formLabelWidth"
                    v-if="editForm.type == '阿米巴预算' || editForm.type == 'CRM' || editForm.type == '微赞' || editForm.type == '微考勤' || editForm.type == 'OKR'"
                    class="lableTop"
                    v-hasPermi="['financial:priceCommission:addlistCover','financial:toolPrice:addlistCover']"
                  >
                    <div class="docControl-box" v-for="(wsid,index) in wisdomBudgetTime" :key="index">
                      <i class="el-icon-remove" @click="removeTimeCon(index)"></i>
                      <el-input v-model="wsid.yearMin"></el-input>
                      <p>~</p>
                      <el-input v-model="wsid.yearMax"></el-input>
                      <p>年，总价优惠</p>
                      <el-input v-model="wsid.discount"></el-input>
                      <p>%；</p>
                    </div>
                    <div class="addBtn">
                      <svg-icon icon-class="add-icon" class="edit_add" @click="addTimeCon"/>
                    </div>
                  </el-form-item>
                  <!-- ---------------------阿米巴预算/CRM/微赞/微考勤/OKR--------------------- end -->
                  <SubBtn>
                    <template slot="btn">
                      <el-button size="mini" @click="reset" round
                        >重设</el-button
                      >
                      <el-button
                        v-hasPermi="['financial:priceCommission:edit','financial:toolPrice:edit']"
                        round
                        size="mini"
                        :disabled="editForm.consultMode == '' ? true : false"
                        type="primary"
                        @click="comfirmEdit"
                        >确 定</el-button>
                    </template>
                  </SubBtn>
                </el-form>
                <!-- 工具定价 end -->
              </div>
            </NewCard>
          </el-col>
        </el-row>
      </div>

      <!-- 修改内容定价 end-->
    </div>
  </main>
</template>
<script>
import { padding } from "@/assets/styles/variables.scss";
import SubBtn from "@/wss/components/subBtn.vue";
import ComSelect from "@/wss/components/comSelect.vue";
import {
  getPriceCommissionListApi,
  getPriceCommissionEditApi,
  getprojectPriceApi,
  editprojectPriceApi,
  getprojectTypeApi,
  getconsultTypeApi,
  editToolPriceApi,
  getToolPriceListApi
} from "@/wss/newApi_3-24/financial/priceCommission.js";
import ComTable from "@/wss/components/comTable.vue";
import ComForm from "@/wss/components/comForm.vue";
import NewCard from "@/wss/components/newCard.vue";
import {
  changeTypeselectselect,
  getfilterParamsing,
} from "@/wss/utils/tool.js";

// 查询咨询列表
import {getConsultTypeListApi,} from "@/wss/newApi_3-24/work/consultType.js";
// 查询项目列表
import {getProjectTypelistApi,} from "@/wss/newApi_3-24/work/projectType.js";

import { changeType, getfilterParams } from "@/wss/utils/wss.js";
import ComTabs from "@/wss/components/ComTabs.vue";
export default {
  name: 'pricing',
  components: {
    ComTable,
    ComForm,
    NewCard,
    ComSelect,
    ComTabs,
    SubBtn,
  },
  data() {
    var validatePass = (rule, value, callback) => {
      if (value == "") return callback(new Error("年龄不能为空"));
      value = Number(value);
      console.log(value);
      if (typeof value == "number") {
        if (value <= 100 && value >= 0) return callback();
      }
      callback(new Error("年龄不能为空"));
    };
    return {
        consultlist: [],//咨询所有类别的数据
        consultallList:[],//用于过滤咨询的全部类型数据
        consultfilterList:[],
        consultname:"",
        consulttopSearchValue:"",

       list: [], //项目所有类别的数据
       allList:[],// 用于过滤项目的全部类型数据
       filterList:[],
       topSearchValue:"",//项目的双向数据绑定
       searchFindShow:false,//搜索发现显示隐藏
       projctname:"",

      currentTitile: "内容定价",
      tabname: "content", //tab切换名称
      currentType: "content",
      // 标签页 数组
      tabList: [
        {
          label: "内容定价",
          name: "content",
        },
        {
          label: "咨询定价",
          name: "consult",
        },
        {
          label: "项目定价",
          name: "project",
        },
        {
          label: "工具定价",
          name: "tool",
        },
      ],
      options: {
        value: "",
        title: "快速筛选",
        list: [
          {
            value: "1",
            label: "正常",
          },
          {
            value: "2",
            label: "失败",
          },
        ],
      },
      padding: padding,
      // 标记第一次过滤
      isFirst: true,
      // 查看对话框
      lookDialogVisible: false,
      isFailtrueFilter: false, //是否过滤失败筛选
      // 保存切换失败和正常筛选的数组
      tempFilterArr: [],
      // 类型数组
      typeArr: [],
      dialogVisible: false,
      // 是否再次过滤筛选条件
      isFilter: true,
      // 表格配置
      config: {
        quanxian: "work:crawler:add",
        // border: true,
        isAdd: true,
        loading: false,
      },
      // 分页参数
      pageing: { pageNum: 1, pageSize: 10, total: 0, type: "1,2,3,4" },
      // 失败和成功状态
      currentStatus: "1",
      // 运行中的数量
      operation: 0,
      activeName: "first",

      // 没有转换过的数据
      noChangeTableList: [],
      // 表单配置
      //咨询等级下拉框
      Browseoptions: [],
      consultform: {
        consultType1:'',
        consultType2:'',
        expertRank: "",
        consultTypeName: "",
      },
      //咨询selet的值
      Commissionvalue:"",

      comForm: {
        modes: [
          {
            formType: "select",
            mode: "expertRank",
            placeholder: "专家等级",
            value: "",
            select: this.Browseoptions,
          },
          {
            placeholder: "咨询类别",
            formType: "input",
            mode: "consultTypeName",
            label: "",
            value: "",
          },
        ],
      },

      // 表格数据
      tableList: [],
      // 表格配置
      tableModes: [
        {
          label: "内容类型",
          mode: "type",
          width: '70',
          options: [
            {
              l: "法律",
              v: 1,
            },
            {
              l: "解答",
              v: 2,
            },
            {
              l: "政策",
              v: 3,
            },
            {
              l: "合同",
              v: 4,
            },
            {
              l: "项目",
              v: 6,
            },
            {
              l: "咨询",
              v: 5,
            },
          ],
        },
        {
          label: "常数(元)",
          mode: "base",
          width: '90',
          showOverflowTooltip: true,
        },
        {
          label: "定价规则",
          mode: "priceRule",
          showOverflowTooltip: true,
          effectiveStatus: true,
          options: [
            {
              l: "常数",
              v: 1,
            },
            {
              l: "上架时间/当前时间*常数",
              v: 2,
            },
          ],
        },
        {
          label: "交付拨比(%)",
          mode: "expertCommission",
          showOverflowTooltip: true,
          width: '90'
        },
        // {
        //   label: "商务拨比（%）",
        //   mode: "cmCommission",
        //   showOverflowTooltip: true,
        //   width: 120,

        // },
        // {
        //   label: "分享拨比（%）",
        //   mode: "shareCommission",
        // },
        {
          label: "拨比规则",
          mode: "expertRule",
          options: [
            {
              l: "常数",
              v: 1,
            },
            {
              l: "实付金额*百分比",
              v: 2,
            },
          ],
        },
        {
          label: "管理拨比(%)",
          mode: "operationsCommission",
          width: '90'
        },
        {
          label: "实体拨比(%)",
          mode: "organizationCommission",
          width: '90'
        },
      ],
      // 修改定价参数
      editForm: {
        type: "",
        base: "",
        expertCommission: "",
        cmCommission: "",
        shareCommission: "",
      },
      //修改内容定价表单判断
      rules: {
        type: [
          {
            required: true,
            message: "请选择定价类型",
            trigger: "string",
            type: "blur",
          },
        ],
        base: [
          {
            required: true,
            message: "不可为空",
            trigger: "blur",
          },
        ],
        expertCommission: [
          {
            required: true,
            message: "0-100之间",
            trigger: "blur",
            validator: validatePass,
          },
        ],
        // 管理拨比(运营拨比)
        operationsCommission: [
          {
            required: true,
            message: "0-100之间",
            trigger: "blur",
            pattern:/(^(\d|[1-9]\d)(\.\d{1,2})?$)|(^100$)/,
          },
        ],
        // 实体拨比(总拨比)
        organizationCommission: [
          {
            required: true,
            message: "0-100之间",
            trigger: "blur",
            pattern:/(^(\d|[1-9]\d)(\.\d{1,2})?$)|(^100$)/,
          },
        ],
        cmCommission: [
          {
            required: true,
            message: "0-100之间",
            trigger: "blur",
            validator: validatePass,
          },
        ],

        shareCommission: [
          {
            required: true,
            message: "0-100之间",
            trigger: "blur",
            validator: validatePass,
          },
        ],
      },
      //修改内容定价 提示框显示状态
      dialogFormVisible: false,

      //修改内容定价 标题宽度
      formLabelWidth: "100px",

      consultTypeList:[], // 咨询列表
      consultTypeTwoList: [],//咨询的二级列表
      projectTypeList:[], // 项目列表
      projectTypeTwoList: [],//咨询的二级列表

      // 项目的条件过滤
      projectform:{
        projectType1:'',//项目一级
        projectType2:'',//项目一级
      },

      // 合同文控参数
      docControl:[],
      // 合同文控参数 end

      // 阿米巴预算参数
      wisdomBudgetUnit:[],//预算单元
      wisdomBudgetTime:[],//购买时长
      // 阿米巴预算参数 end

      editConWis:{
        trialDays: null,//试用时间
        trialNum: null,//试用份数
      },
    };
  },
  created() {
    this.getPriceCommissionList();
  },
  mounted(){
    this.getConsultTypeListFn() // 获取咨询类型
    this.getProjectTypeListFn() // 获取项目类型
  },
  methods: {
    // 获取咨询类型
    async getConsultTypeListFn() {
      let { code, rows } = await getConsultTypeListApi();
      if (code != 200) return;
      this.consultTypeList = JSON.parse(JSON.stringify(rows));
      // 默认选中第一项
      this.consultform.consultType1 = rows[0].id
      // 过滤出二级列表 consultTypeTwoList
      let one = this.consultTypeList.find(item=>{
        return item.id == this.consultform.consultType1
      })
      // 二级列表
      this.consultTypeTwoList = one.children
    },

    // 获取项目类型
    async getProjectTypeListFn() {
      let isTools = true
      let { code, rows } = await getProjectTypelistApi();
      if (code != 200) return;
      this.projectTypeList = JSON.parse(JSON.stringify(rows));
      // 默认选中第一项
      this.projectform.projectType1 = rows[0].id
      // 过滤出二级列表 projectTypeTwoList
      let one = this.projectTypeList.find(item=>{
        return item.id == this.projectform.projectType1
      })
      // 二级列表
      this.projectTypeTwoList = one.children
    },

    validatePass(rule, value, callback) {
      if (value == "") return callback(new Error("年龄不能为空"));
      value = Number(value);
      console.log(value);
      if (typeof value == "number") {
        if (value <= 1 && value >= 0) return callback();
      }
      callback(new Error("年龄不能为空"));
    },
    // tab页切换时
    currentSelect({ label, index, name }) {
      this.tabname = name;
      console.log(label, "label");
      console.log(name, "name");

      switch (name) {
        case "consult":
          this.pageing.type = "5";
          this.projctname=""
          this.topSearchValue="",
          this.tableModes = [
            // {
            //   label: "咨询方式",
            //   mode: "consultWay",
            // },
            {
              label: "专家等级",
              mode: "expertRank",
              width: 100,
              showOverflowTooltip: true,
            },
            {
              label: "咨询类别",
              mode: "consultTypeName",
            },
            {
              label: "咨询类型",
              mode: "consultSite",
              showOverflowTooltip: true,
              width: 90,
              effectiveStatus: true,
              options: [
                {
                  l: "图文咨询",
                  v: 0,
                },
                {
                  l: "现场咨询",
                  v: 1,
                },
              ],
            },
            {
              label: "常数(元)",
              mode: "base",
              width: 100,
              showOverflowTooltip: true,
            },
            {
              label: "定价规则",
              mode: "priceRule",
              showOverflowTooltip: true,
              width: 120,
              effectiveStatus: true,
              options: [
                {
                  l: "常数",
                  v: 1,
                },
                {
                  l: "常数",
                  v: 2,
                },
              ],
            },
            {
              label: "交付分成(元)",
              mode: "expertCommission",
              showOverflowTooltip: true,
            },
            {
              label: "管理拨比(%)",
              mode: "operationsCommission",
              width: '90'
            },
            {
              label: "实体拨比(%)",
              mode: "organizationCommission",
              width: '90'
            },

            // {
            //   label: "分享分成",
            //   mode: "shareCommission",
            // },
            // {
            //   label: "商务拨比（%）",
            //   mode: "cmCommission",
            //   showOverflowTooltip: true,
            //   width: 120,

            // },
          ];
          (this.rules = {
            type: [
              {
                required: true,
                message: "请选择咨询方式",
                trigger: "blur",
              },
            ],
            base: [
              {
                required: true,
                message: "不可为空",
                trigger: "blur",
              },
            ],
            expertCommission: [
              {
                required: true,
                message: "请输入分成金额",
                trigger: "blur",
              },
            ],
            cmCommission: [
              {
                required: true,
                message: "请输入分成金额",
                trigger: "blur",
              },
            ],

            shareCommission: [
              {
                required: true,
                message: "0-100之间",
                trigger: "blur",

                validator: this.validatePass,
              },
            ],
            // 管理拨比(运营拨比)
            operationsCommission: [
              {
                required: true,
                message: "0-100之间",
                trigger: "blur",
                pattern:/(^(\d|[1-9]\d)(\.\d{1,2})?$)|(^100$)/,
              },
            ],
            // 实体拨比(总拨比)
            organizationCommission: [
              {
                required: true,
                message: "0-100之间",
                trigger: "blur",
                pattern:/(^(\d|[1-9]\d)(\.\d{1,2})?$)|(^100$)/,
              },
            ],
          }),
            (this.editForm = {
              consultMode: "",
              base: "",
              expertCommission: "",
              cmCommission: "",
              shareCommission: "",
              operationsCommission:"",
              organizationCommission:"",
            });
            this.$nextTick(() => {
              this.$refs.form.resetFields();//重置并清除验证
            });
          break;

        case "content":
          this.pageing.type = "1,2,3,4,";
          this.tableModes = [
            {
              label: "内容类型",
              mode: "type",
              options: [
                {
                  l: "法律",
                  v: 1,
                },
                {
                  l: "解答 ",
                  v: 2,
                },
                {
                  l: "政策 ",
                  v: 3,
                },
                {
                  l: "合同 ",
                  v: 4,
                },
                {
                  l: "咨询 ",
                  v: 5,
                },
                {
                  l: "项目",
                  v: 6,
                },
              ],
            },
            {
              label: "常数(元)",
              mode: "base",
              width: 100,
              showOverflowTooltip: true,
            },
            {
              label: "定价规则",
              mode: "priceRule",
              showOverflowTooltip: true,
              effectiveStatus: true,
              options: [
                {
                  l: "上架时间/当前时间*常数",
                  v: 1,
                },
                {
                  l: "上架时间/当前时间*常数",
                  v: 2,
                },
              ],
            },
            {
              label: "交付分成",
              mode: "expertCommission",
              showOverflowTooltip: true,
            },
            // {
            //   label: "商务拨比（%）",
            //   mode: "cmCommission",
            //   showOverflowTooltip: true,
            // },
            // {
            //   label: "分享拨比（%）",
            //   mode: "shareCommission",
            // },
            {
              label: "拨比规则",
              mode: "expertRule",
              options: [
                {
                  l: "实付金额*百分比",
                  v: 1,
                },
                {
                  l: "实付金额*百分比",
                  v: 2,
                },
              ],
            },
            {
              label: "管理拨比(%)",
              mode: "operationsCommission",
              width: '90'
            },
            {
              label: "实体拨比(%)",
              mode: "organizationCommission",
              width: '90'
            },
          ];
          this.editForm = {
            type: "",
            base: "",
            expertCommission: "",
            cmCommission: "",
            shareCommission: "",
            operationsCommission:"",
            organizationCommission:"",
          };
          this.rules = {
            type: [
              {
                required: true,
                message: "请选择定价类型",
                trigger: "string",
                type: "blur",
              },
            ],
            base: [
              {
                required: true,
                message: "不可为空",
                trigger: "blur",
              },
            ],
            expertCommission: [
              {
                required: true,
                message: "请输入分成金额",
                trigger: "blur",
              },
            ],
            cmCommission: [
              {
                required: true,
                message: "请输入分成金额",
                trigger: "blur",
              },
            ],

            shareCommission: [
              {
                required: true,
                message: "0-100之间",
                trigger: "blur",

                validator: this.validatePass,
              },
            ],
            // 管理拨比(运营拨比)
            operationsCommission: [
              {
                required: true,
                message: "0-100之间",
                trigger: "blur",
                pattern:/(^(\d|[1-9]\d)(\.\d{1,2})?$)|(^100$)/,
              },
            ],
            // 实体拨比(总拨比)
            organizationCommission: [
              {
                required: true,
                message: "0-100之间",
                trigger: "blur",
                pattern:/(^(\d|[1-9]\d)(\.\d{1,2})?$)|(^100$)/,
              },
            ],
          };
          this.$nextTick(() => {
            this.$refs.form.resetFields();//重置并清除验证
          });
          break;
        case "project":
          this.pageing.type = "";
          this.consultname=""
          this.consulttopSearchValue=""
          this.tableModes = [
            {
              label: "项目类别",
              mode: "name",

              // options: [
              //   {
              //     l: "标准项目",
              //     v: 1,
              //   },
              //   {
              //     l: " 议价项目",
              //     v: 2,
              //   },

              // ],
            },

            {
              label: "常数(元)",
              mode: "base",
              showOverflowTooltip: true,
            },
            {
              label: "定价规则",
              mode: "priceRule",
              showOverflowTooltip: true,
              effectiveStatus: true,
              options: [
                {
                  l: "常数",
                  v: 1,
                },
                {
                  l: "上架时间/当前时间*常数",
                  v: 2,
                },
              ],
            },

            {
              label: "交付分成(元)",
              mode: "expertCommission",
              showOverflowTooltip: true,
            },
            {
              label: "管理拨比(%)",
              mode: "operationsCommission",
              width: '90'
            },
            {
              label: "实体拨比(%)",
              mode: "organizationCommission",
              width: '90'
            },
          ];
          this.editForm = {
            type: "",
            base: "",
            expertCommission: "",
            cmCommission: "",
            shareCommission: "",
            operationsCommission:"",
            organizationCommission:"",
          };
          this.rules = {
            type: [
              {
                required: true,
                message: "请选择定价类型",
                trigger: "string",
                type: "blur",
              },
            ],

            expertCommission: [
              {
                required: true,
                message: "请输入分成金额",
                trigger: "blur",
              },
            ],
            base: [
              {
                required: true,
                message: "不可为空",
                trigger: "blur",
              },
            ],
            // expertCommission: [
            //   {
            //     required: true,
            //     message: "0-100之间",
            //     trigger: "blur",

            //     validator: this.validatePass,
            //   },
            // ],
            // cmCommission: [
            //   {
            //     required: true,
            //     message: "0-100之间",
            //     trigger: "blur",

            //     validator: this.validatePass,
            //   },
            // ],

            shareCommission: [
              {
                required: true,
                message: "0-100之间",
                trigger: "blur",
                validator: this.validatePass,
              },
            ],
            // 管理拨比(运营拨比)
            operationsCommission: [
              {
                required: true,
                message: "0-100之间",
                trigger: "blur",
                pattern:/(^(\d|[1-9]\d)(\.\d{1,2})?$)|(^100$)/,
              },
            ],
            // 实体拨比(总拨比)
            organizationCommission: [
              {
                required: true,
                message: "0-100之间",
                trigger: "blur",
                pattern:/(^(\d|[1-9]\d)(\.\d{1,2})?$)|(^100$)/,
              },
            ],
          };
          this.$nextTick(() => {
            this.$refs.form.resetFields();//重置并清除验证
          });
          break;
        case "tool":
          this.pageing.type = "20,21,22,23,25,26,27,28,29";
          this.tableModes = [
            {
              label: "工具名称",
              mode: "type",
              options: [
                {
                  l: "OKR",
                  v: 29,
                },
                {
                  l: "微考勤",
                  v: 28,
                },
                {
                  l: "微赞",
                  v: 27,
                },
                {
                  l: "CRM",
                  v: 26,
                },
                {
                  l: "税账医生",
                  v: 25,
                },
                {
                  l: "合同文控",
                  v: 23,
                },
                {
                  l: "阿米巴预算",
                  v: 22,
                },
                {
                  l: "模拟诉讼",
                  v: 21,
                },
                {
                  l: "合同智审",
                  v: 20,
                },
              ],
            },
            {
              label: "常数(元)",
              mode: "base",
              width: 100,
              showOverflowTooltip: true,
            },
            {
              label: "定价规则",
              mode: "priceRule",
              showOverflowTooltip: true,
              width: 100,
              effectiveStatus: true,
              options: [
                {
                  l: "常数",
                  v: 1,
                },
                {
                  l: "常数",
                  v: 2,
                },
                {
                  l: "常数",
                  v: 3,
                },
                {
                  l: "常数",
                  v: 4,
                },
              ],
            },
            {
              label: "交付分成(元)",
              mode: "expertCommission",
              showOverflowTooltip: true,
            },
            {
              label: "管理拨比(%)",
              mode: "operationsCommission",
              width: '90'
            },
            {
              label: "实体拨比(%)",
              mode: "organizationCommission",
              width: '90'
            },
            // {
            //   label: "渠道拨比（%）",
            //   mode: "cmCommission",
            //   showOverflowTooltip: true,
            //   width: 140,

            // },
            // {
            //   label: "商务经理拨比（%）",
            //   mode: "shareCommission",
            //   width: 140,

            // }, 
            // {
            //   label: "商务总监拨比（%）",
            //   mode: "shareCommission",
            //   width: 160,

            // },
          ];
          this.editForm = {
            type: "",
            base: "",
            expertCommission: "",
            cmCommission: "",
            shareCommission: "",
            operationsCommission:"",
            organizationCommission:"",
          };
          this.rules = {
            type: [
              {
                required: true,
                message: "请选择定价类型",
                trigger: "string",
                type: "blur",
              },
            ],
            base: [
              {
                required: true,
                message: "不可为空",
                trigger: "blur",
              },
            ],
            expertCommission: [
              {
                required: true,
                message: "请输入分成金额",
                trigger: "blur",
              },
            ],
            cmCommission: [
              {
                required: true,
                message: "0-100之间",
                trigger: "blur",

                validator: this.validatePass,
              },
            ],

            shareCommission: [
              {
                required: true,
                message: "0-100之间",
                trigger: "blur",
                validator: this.validatePass,
              },
            ],
            // 管理拨比(运营拨比)
            operationsCommission: [
              {
                required: true,
                message: "0-100之间",
                trigger: "blur",
                pattern:/(^(\d|[1-9]\d)(\.\d{1,2})?$)|(^100$)/,
              },
            ],
            // 实体拨比(总拨比)
            organizationCommission: [
              {
                required: true,
                message: "0-100之间",
                trigger: "blur",
                pattern:/(^(\d|[1-9]\d)(\.\d{1,2})?$)|(^100$)/,
              },
            ],
          };
          this.$nextTick(() => {
            this.$refs.form.resetFields();//重置并清除验证
          });
          break;
      }
      if (name == "project") {
        this.getprojectPriceApifn();
        this.currentType = name;
        // console.log(this.currentType, "是啊");
        this.currentTitile = label;
        // console.log(this.$refs.form);
        this.$nextTick(() => {
          this.$refs.form.resetFields();
        });
      } else {
        this.getPriceCommissionList();
        // console.log(item);
        this.currentType = name;
        // console.log(this.currentType, "是啊");
        this.currentTitile = label;
        // console.log(this.$refs.form);
        this.$nextTick(() => {
          this.$refs.form.resetFields();
        });
      }
    },
    // 重设
    reset() {
      this.editForm = {
        type: "",
        base: "",
        priceRule: "",
        expertCommission: "",
        cmCommission: "",
        shareCommission: "",
      };
      this.pageing = { pageNum: 1, pageSize: 10, total: 0, type: "1,3,4,6" };
    },

    // 修改定价确认
    async comfirmEdit() {
      await this.$refs.form.validate();
      let editForm = this.editForm;
      const currentType = this.currentType;
      if (currentType !== "project") {
        if (currentType == "consult") {
          // 咨询
          // editForm.consultMode = changeTypeselectselect(editForm.consultMode);
        } else if (currentType == "content") {
          // 内容
          editForm.type = changeType(editForm.type);
        } else if (currentType == "tool") {
          // 工具
          editForm.type = changeTypeselectselect(editForm.type);
          // 如果是合同文控和阿米巴预算走这里
          if(editForm.type==23){
            this.editDocControl() // 合同文控编辑
          }
          if(editForm.type==22||editForm.type==26||editForm.type==27||editForm.type==28||editForm.type==29){
            this.editWisdomBudget() // 阿米巴预算/CRM/微赞/微考勤/OKR 编辑 
          }
        }
        let { code, msg } = await getPriceCommissionEditApi(editForm);
        if (code != 200) return;
        editForm.type = changeTypeselectselect(editForm.type);
        this.editForm = {};
        this.getPriceCommissionList();
        this.$message({
          message: msg,
          type: "success",
        });
      } else {
        // 项目
        console.log("project");
        // editForm.type = changeTypeselectselect(editForm.type);
        let { code, msg } = await editprojectPriceApi(editForm);
        if (code != 200) return;
        this.editForm = {};
        this.getprojectPriceApifn();
        this.$message({
          message: msg,
          type: "success",
        });
      }
    },
    // 表格行被点击了
    RowClickFn(row) {
      console.log(row, "1111表格行被点击了");
      // 1法律 3头条 4问答 6超级合同 7咨询
      let changeRow = JSON.parse(JSON.stringify(row));

      const currentType = this.currentType;
      // 咨询
      if (currentType == "consult") {
        // changeRow.type = changeTypeselectselect(changeRow.type);
        console.log(changeRow, "222");

        // 内容
      } else if (currentType == "content") {
        changeRow.type = changeType(changeRow.type);
      } else if (currentType == "project") {
        // changeRow.type = changeTypeselectselect(changeRow.type);
      } else if (currentType == "tool") {
        //获取 阿米巴预算/CRM/微赞/微考勤/OKR 的定价参数
        if(changeRow.type=='22'||changeRow.type=='23'||changeRow.type=='26'||changeRow.type=='27'||changeRow.type=='28'||changeRow.type=='29'){
          //获取 阿米巴预算/CRM/微赞/微考勤/OKR 的定价参数
          this.getToolPriceList(changeRow.id,changeRow.type) 
        }
        changeRow.type = changeTypeselectselect(changeRow.type);
      }

      this.editForm = changeRow;
    },
    // 编辑
    edit() {
      this.dialogFormVisible = true;
    },

    getfilterParamsFn(tableList) {
      let s = new Set();
      for (let index = 0; index < tableList.length; index++) {
        s.add(tableList[index].type);
        // const element = tableList[index];
      }
      let arr = Array.from(s, (item) => {
        return {
          type: item,
        };
      });
      return getfilterParams(arr);
    },
    // 获取咨询列表
    async getPriceCommissionList() {
      const _this = this;
      const { pageNum, pageSize } = _this.pageing;

      let data = {}
      if(this.tabname == "consult"){
        // 如果是咨询定价
        data = {
          pageNum,
          pageSize,
          expertLevel:this.Commissionvalue,
          consultType:this.consultname,
          consultType1: this.consultform.consultType1,
          consultType2: this.consultform.consultType2,
          type:this.pageing.type
        }
      }else{
        // 如果是内容定价和工具定价
        data = {
          pageNum,
          pageSize,
          expertLevel:this.Commissionvalue,
          consultType:this.consultname,
          type:this.pageing.type
        }
      }

      let { code, rows, total } = await getPriceCommissionListApi(data);
      if (code != 200) return;

      let tableList = JSON.parse(JSON.stringify(rows));
      _this.pageing.total = total;
      // 找出过滤类型
      if (_this.isFirst) {
        let arr = _this.getfilterParamsFn(tableList);
        _this.comForm.modes.forEach((item) => {
          item.select = arr;
        });
        _this.isFirst = false;
      }
      let obj = rows;
      for (const key in obj) {
        this.Browseoptions.push({
          value: obj[key].expertLevel,
          label: obj[key].expertRank,
        });
      }
      let newarr = [];
      let map = new Map();
      for (let item of this.Browseoptions) {
        if (!map.has(item.value)) {
          if (item.value) {
             map.set(item.value, item);
          }
        }
      }
      this.Browseoptions = [...map.values()];
      _this.tableList = tableList;
    },
    //查询三级类别
    async getconsultTypeApifn() {
      let { code, rows, total } = await getconsultTypeApi();
      if (code != 200) return;
      // 用于过滤-----------------------
       this.consultlist=rows
        // 获取全部一级类型
        let oneType = []
        this.consultlist.forEach(item=>{
          oneType.push(item)
        })
        // 获取全部二级类型
        let secondType = []
        this.consultlist.forEach(item=>{
          if(item.children){
            item.children.forEach(k=>{
              secondType.push(k)
            })
          }
        })
        let threeType = [] //全部三级类型
        secondType.forEach(item=>{
          if(item.children){
            item.children.forEach(i => {
              threeType.push(i)
            });
          }
        })
        this.consultallList = [...threeType]
        this.consultallList.map((item)=>{
            console.log(item.name,"name");
        })
        this.consultfilterList = this.consultallList
     
    },
    
    //项目设置查询
    async getprojectPriceApifn() {
      const _this = this;
      const {pageNum,pageSize}=_this.pageing
      let { code, rows, total } = await getprojectPriceApi({
        pageNum,
        pageSize,
        projectType:this.projctname,
        projectType1: this.projectform.projectType1,
        projectType2: this.projectform.projectType2,
      });
      if (code != 200) return;
      let tableList = JSON.parse(JSON.stringify(rows));
      _this.pageing.total = total;
      _this.tableList = tableList;
    },
    // 项目搜索getprojectTypeApi
      async getprojectTypeApifn() {
      const _this = this;
      const {pageNum,pageSize}=_this.pageing
      let { code, rows, total } = await getprojectTypeApi({
      });
      if (code != 200) return;
      this.list = rows;

         // 用于过滤-----------------------
        // 获取全部一级类型
        let oneType = []
        this.list.forEach(item=>{
          oneType.push(item)
        })
        // 获取全部二级类型
        let secondType = []
        this.list.forEach(item=>{
          if(item.children){
            item.children.forEach(k=>{
              secondType.push(k)

            })
          }
        })
        let threeType = [] //全部三级类型
        secondType.forEach(item=>{
          if(item.children){
            item.children.forEach(i => {
              threeType.push(i)
            });
          }
        })
        this.allList = [...threeType]
        this.filterList = this.allList
    },
    //输入框改变的时候过滤
    changeValue(){
      //过滤数据 this.topSearchValue
      this.allList = this.filterList.filter(item=>item.name.includes(this.topSearchValue))
    },
     //搜索框激活状态
    focusInput(){
      //项目类型
      this.getprojectTypeApifn();
      //显示搜索发现
      this.searchFindShow=true
    },
        //搜索框失去焦点
    blurInput(){
      //隐藏搜索发现
      this.searchFindShow=false
    },
      //点击项目搜索发现的某一条
    clickSearchList(list,index){
      console.log(list,"1231313");
      this.projctname=list.id
      this.getprojectPriceApifn();
      this.topSearchValue=list.name
       this.searchFindShow=false
    },
      //点击咨询搜索发现的某一条
     consultclickSearchList(list,index){
      this.consultname=list.id
      this.consulttopSearchValue=list.name
       this.searchFindShow=false
      this.getPriceCommissionList();
    },
    //输入框改变的时候过滤
    consultchangeValue(){
      //过滤数据 this.topSearchValue
      this.consultallList = this.consultfilterList.filter(item=>item.name.includes(this.consulttopSearchValue))
    },
     //搜索框激活状态
    consultfocusInput(){
      this.getconsultTypeApifn();
      //显示搜索发现
      this.searchFindShow=true
    },
        //搜索框失去焦点
    consultblurInput(){
      //隐藏搜索发现
      this.searchFindShow=false
    },
    
    handleClick(tab, event) {
      console.log(tab, event);
    },

    // 选择专家等级
    BrowseFromFn(value) {
      this.Commissionvalue=value.expertRank
      this.getPriceCommissionList();
    },

    // 改变咨询一级类别
    changeConsultOne(consultform){
      // 过滤出二级列表 consultTypeTwoList
      let one = this.consultTypeList.find(item=>{
        return item.id == consultform.consultType1
      })
      // 二级列表
      this.consultTypeTwoList = one.children
      this.getPriceCommissionList();
    },

    // 改变咨询二级类别
    changeConsultTwo(consultform){
      this.getPriceCommissionList();
    },

    // 修改项目一级类别
    changeProjectOne(projectform){
      // 过滤出二级列表 projectTypeTwoList
      let one = this.projectTypeList.find(item=>{
        return item.id == projectform.projectType1
      })
      // 二级列表
      this.projectTypeTwoList = one.children
      this.getprojectPriceApifn() //查询项目
    },

    // 改变项目二级类别
    changeProjectTwo(projectform){
      this.getprojectPriceApifn() //查询项目
    },

    // inquireFn(paramsArr) {
    //   console.log(paramsArr);
    //   let { pageing } = this;
    //   // 筛选数据
    //   paramsArr.forEach((item) => {
    //     for (const key in item) {
    //       this.pageing[key] = item[key];
    //     }
    //   });
    //   if (pageing.type == "" || !pageing.type) {
    //     pageing.type = "1,3,4,6";
    //   }
    //   pageing.pageNum = 1;
    //   this.getPriceCommissionList();
    // },
    // 当前页发生改变时
    handleCurrentChange(pageNum) {
      this.pageing.pageNum = pageNum;
      if (this.currentType == "project") {
        this.getprojectPriceApifn();
      } else {
        this.getPriceCommissionList();
      }
    },
    // 页容量发生改变
    handleSizeChange(pageSize) {
      this.pageing.pageSize = pageSize;
      if (this.currentType == "project") {
        this.getprojectPriceApifn();
      } else {
        this.getPriceCommissionList();
      }
    },

    // -------------------------合同文控-------------------------
    // 删除一条参数
    removeDocCon(index){
      // 根据下标去删数据
      this.docControl.splice(index,1)
    },

    // 添加一条参数
    addDocCon(){
      this.docControl.push({min:'',max:'',amount:''})
    },

    // 修改合同文控
    editDocControl(){
      // 整理数据
      this.docControl.forEach(item=>{
        item.priceCommission = this.editForm.id
        item.trialNum = this.editConWis.trialNum
      })
      this.editToolPrice(this.docControl)
    },

    // -------------------------合同文控-------------------------end

    //  -------------------------阿米巴预算 -------------------------
    removeUnitCon(index){
      // 根据下标去删数据
      this.wisdomBudgetUnit.splice(index,1)
    },

    addUnitCon(){
      this.wisdomBudgetUnit.push({min:'',max:'',amount:''})
    },

    removeTimeCon(index){
      // 根据下标去删数据
      this.wisdomBudgetTime.splice(index,1)
    },

    addTimeCon(){
      this.wisdomBudgetTime.push({yearMin:'',yearMax:'',discount:''})
    },

    // 修改 阿米巴预算/CRM/微赞/微考勤/OKR
    editWisdomBudget(){
      // 整理数据
      this.wisdomBudgetUnit.forEach((item)=>{
        item.trialNum = this.editConWis.trialNum //试用数量
        item.trialDays = this.editConWis.trialDays //试用时间
      })
      this.wisdomBudgetTime.forEach((item)=>{
        item.trialNum = this.editConWis.trialNum //试用数量
        item.trialDays = this.editConWis.trialDays //试用时间
      })
      let unit = JSON.parse(JSON.stringify(this.wisdomBudgetUnit))
      let time = JSON.parse(JSON.stringify(this.wisdomBudgetTime))
      let data = [...unit, ...time]
      
      // 添加id
      data.forEach(item => {
        item.priceCommission = this.editForm.id
      });
      // 发请求
      this.editToolPrice(data)
    },
    //  -------------------------阿米巴预算 -------------------------end

    // 阿米巴预算/CRM/微赞/微考勤/OKR编辑接口
    async editToolPrice(data){
      // console.log(data,'阿米巴预算/CRM/微赞/微考勤/OKR');
      let result = await editToolPriceApi(data)
      if(result.code == 200){
        this.editForm.type = changeTypeselectselect(this.editForm.type);
        this.$message({
          message: '编辑成功！',
          type: "success",
        });
      }
    },

    // 获取阿米巴预算/CRM/微赞/微考勤/OKR 的定价参数
    async getToolPriceList(id,type){
      console.log(id,type,'获取阿米巴预算和合同文控的定价参数');
      let params = {
        price_commission: id,
      }
      let result = await getToolPriceListApi(params)
      if(result.code==200){
        if(type == '23'){
          // 合同文控
          this.docControl = JSON.parse(JSON.stringify(result.rows))
          this.docControl.forEach(item=>{
            this.editConWis.trialNum = item.trialNum
          })
        }
        if(type == '22'||type == '26'||type == '27'||type == '28'||type == '29'){
          this.wisdomBudgetUnit = [] //先清空
          this.wisdomBudgetTime = [] //先清空
          result.rows.forEach(item=>{
            this.editConWis.trialNum = item.trialNum //试用数量
            this.editConWis.trialDays = item.trialDays //试用时间
            // 预算单元
            if(item.min){
              this.wisdomBudgetUnit.push({
                priceCommission: item.priceCommission,
                min: item.min,
                max: item.max,
                amount: item.amount
              })
            }
            // 购买时长
            if(item.yearMin){
              this.wisdomBudgetTime.push({
                priceCommission: item.priceCommission,
                yearMin: item.yearMin,
                yearMax: item.yearMax,
                discount: item.discount
              })
            }
          })
        }
      }
    },
  },
};
</script>

<style lang="scss" scoped>
ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.wss-container {
  display: flex;
  flex-direction: column;
}
.el-tabs {
  height: 40px;
  margin-bottom: 20px;
}
.label-box-content {
  height: calc(100% - 60px);
}
.label-box-content .el-row {
  height: 100%;
  margin-bottom: 0;
}
.label-box-content .el-col {
  height: 100%;
}
.label-box-content .el-card {
  height: 100%;
}

::v-deep .el-card .el-card__body {
  position: relative;
  height: 100%;
}
::v-deep .el-card .el-card__body > div {
  padding-top: 0 !important;
  height: calc(100% - 60px);
  overflow-y: auto;
}
.container {
  padding: 10px;
  background-color: rgba(123, 123, 123, 0.2);
  ::v-deep .container .right {
    margin-top: 0px;
  }
  .title {
    font-size: 28px;
    font-weight: 900;
    margin-bottom: 20px;
  }
  ::v-deep .el-card {
    border-radius: 0;
    border: 0;
  }
  ::v-deep .el-tabs__nav-scroll {
    overflow: hidden;
    background: #ffffff;

    box-sizing: border-box;
    padding-left: 20px;
    height: 70px;
    line-height: 70px;
  }
  ::v-deep .el-tabs__item.is-active,
  ::v-deep .el-tabs__item:hover {
    color: #f97f2a;
  }

  ::v-deep .el-tabs__active-bar {
    background-color: transparent;
  }
  // ::v-deep .el-tabs__item:hover {
  //   color: #f97f2a;
  // }
}

::v-deep .el-table .el-table__body {
  table-layout: fixed !important;
}

.content-box {
  // display: flex;
  width: 100%;
  height: 100%;
  .table {
    flex: 1.8;
  }
  .edit-box {
    flex: 0.5;
    position: relative;
  }
}

.edit-div {
  margin-top: 30px;
}
::v-deep .edit-div .el-form-item__label {
  color: #2e3f5e;
}
::v-deep .edit-div .lableTop {
  display: flex;
  flex-wrap: wrap;
}
::v-deep .edit-div .lableTop .el-form-item__label {
  width: 100%!important;
  margin-bottom: 10px;
}
::v-deep .edit-div .lableTop .el-form-item__content {
  width: 100%;
  margin-left: 0!important;
}


/* 右侧按钮样式 */
::v-deep .subBtn {
  padding: 8px 30px;
}
::v-deep .subBtn .el-button {
  width: 100px;
  padding: 8px 0;
  font-size: 14px;
  color: #606e84;
}
::v-deep .subBtn .el-button--primary {
  background-color: #f87a23;
  border-color: #f87a23;
  color: #fff;
}
::v-deep .block {
  margin-bottom: 20px;
}
/* 顶部右边搜索 */
.top .el-form{
  display: flex;
  justify-content: space-between;
}
.top .el-form .el-form-item{
  margin-bottom:0;
  padding: 5px;
}
.top .el-form .el-form-item .el-select{
  width: 110px;
}

.topRight{
  position: relative;
  margin: 5px 0px;
}
.topSearch{
  width: 160px;
}
::v-deep .topSearch .el-input__suffix{
  right: 15px;
}
.topSearch i{
  display: inline-block;
  font-size: 16px;
  margin-top: 7px;
}
::v-deep .topSearch .el-input__inner{
  height: 36px;
  line-height: 36px;
  border-radius: 18px;
}
::v-deep .topSearch .el-input__inner:focus{
  border: 2px solid #F87A23;
  border-radius: 18px 18px 0 0;
  border-bottom: 1px solid #EFEFEF;
}
.topSearchFind{
  position: absolute;
  width: 100%;
  border: 2px solid #F87A23;
  border-top: 0;
  background-color: #fff;
  border-radius: 0 0 18px 18px;
  padding: 10px 0;
  z-index: 999;
  overflow: hidden;
}
.topSearchFind ul::-webkit-scrollbar {
  width: 0;
  height: 0;
}
.topSearchFind ul{
  max-height: 200px;
  overflow-y: auto;
}
.topSearchFind ul>li{
  width: 100%;
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  line-height: 34px;
  font-weight: 400;
  color: #333333;
  cursor: pointer;
  transition: all 0.3s;
  margin: 0 20px;
}
.topSearchFind ul>li:hover{
  background-color: #F4F5F8;
  color: #F87A23;
}
.topSearchFind ul>li>span{
  font-size: 12px;
  color: #999;
}

/* 顶部右边搜索 end*/

// 合同文控
.docControl-box{
  display: flex;
  align-items: center;
  color: #333;
  margin-bottom: 10px;
  i{
    color: #999;
    cursor: pointer;
  }
  p{
    margin: 0;
  }
  .el-input{
    width: 48px;
    margin: 0 5px;
  }
}

::v-deep .docControl-box .el-input__inner{
  padding: 0 3px;
}

.addBtn{
  border-bottom: 1px solid #EFEFEF;
  .edit_add{
    font-size: 16px;
    color: #333;
    cursor: pointer;
  }
}

// 合同文控 end
</style>